import { defHttp } from '/@/utils/http/axios';
import { AuthorSearchModel, AuthorVOModel } from './model/authorModel';
import { BasicDetailModel, BasicDelModel } from '../model/baseModel';

enum Api {
  BaseApi = '/microresource/author',
}

/**
 * @description: 获取作家列表数据
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const getAuthorPageApi = (data: AuthorSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/page', data });
};

/**
 * @description: 获取作家集合数据
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const getAuthorListApi = (data: AuthorSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/list', data });
};

/**
 * @description: 获取作家详细信息
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const getAuthorDetailApi = (authorId: string) => {
  const data: BasicDetailModel = {
    id: authorId,
  };
  return defHttp.post({ url: Api.BaseApi + '/detail', data });
};

/**
 * @description: 新增作家
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const saveAuthorApi = (data: AuthorVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/add', data });
};

/**
 * @description: 修改作家
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const updateAuthorApi = (data: AuthorVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/edit', data });
};

/**
 * @description: 删除作家
 * @author xuyong
 * @date 2025-05-02 14:45:02
 */
export const delAuthorApi = (authorIds: string[]) => {
  const data: BasicDelModel = {
    ids: authorIds,
  };
  return defHttp.post({ url: Api.BaseApi + '/delete', data });
};
